﻿#include "LampControl.h"

LampControl::LampControl(QObject *parent) : QObject(parent)
{
    m_tracking = false;
    for(int i = 0; i < 10; i++)
    {
        m_brightness[i] = -1;
    }
}

void LampControl::onLensChanged(int oldlens, int newlens)
{
    if(oldlens == 0) oldlens = m_lens;
    if(newlens >=0 && newlens < 10)
    {
        m_lens = newlens;
        m_brightness[m_lens] = value();
        if(m_brightness[m_lens] == -1)// -1 表示没有设置过亮度
        {
            m_brightness[m_lens] = m_brightness[oldlens];
        }
        if(m_tracking)
        {
            setValue(m_brightness[m_lens]);
        }
    }
}
